/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.acme.persistence;

import com.acme.model.Stock;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 *
 * @author General
 */
@Repository // a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning.
public class StockDaoImpl extends AbstractHbmDao<Stock, Long> implements StockDao {

    @Autowired
    public StockDaoImpl(SessionFactory sf) {
            super(sf);
    }
    
    @Override
    protected String getEntityName() {
        return "com.acme.model.Stock";
    }

    @Override
    protected String getIdName() {
        return "stock_id";
    }

    @Override
    public List<Stock> findBySymbol(String symbol) {
        System.out.println("DAO symbol: " + symbol);
        Session s = sf.getCurrentSession();		
        return s.createQuery("from Stock where symbol = '" + symbol + "'").list();
    }
    
}
